<fieldset id="infosAll">
</fieldset>
<p>
	<input type="button" value="确定" onclick="sureIt();"/>
	<input type="button" value="取消" onclick="hideIt();"/>
</p>

<script type="text/javascript">
	var tables = $('infosField').getElementsByTagName('table');
	var newFieldset = $('infosAll');
	for(var i=0;i<tables.length;i++) {
		var table = tables[i];
		var selects = table.getElementsByTagName('select');
		var newTable = ("<table id='new_"+table.id+"></table>").createElement();
		var newTr = ("<tr></tr>").createElement();
		var newTd = ("<td></td>").createElement();
		var newSelect = ("<select style='width:10em' multiple id='new_"+ table.id  +"sel' size=10></select>").createElement();
		var index=0;
		for(var j=0;j<selects.length;j++) {
				var eachSelect = selects[j];
				var options = eachSelect.getElementsByTagName('option');
				for(var k=0;k<options.length;k++) {
						var eachOption = options[k];
						if(j == 0) {
								var tOp = new Option(eachOption.text,eachOption.value);
								tOp.selected = true;
								newSelect.options[index++] = tOp;
								//var newOption = ("<option selected=true value='" + eachOption.value + "'>"+ eachOption.text +"</option>").createElement();
								//newSelect.appendChild(newOption);
						} else {
								var tOp = new Option(eachOption.text,eachOption.value);
								newSelect.options[index++] = tOp;
								//var newOption = ("<option selected=false value='" + eachOption.value + "'>"+ eachOption.text +"</option>").createElement();
								//newSelect.appendChild(newOption);
						}
				}
		}
		var spanText = table.getElementsByTagName('span')[0];
		var newSpan = ("<span>" + spanText.innerHTML +"</span>").createElement();
		newTd.insertBefore(newSelect, newTd.firstChild);
		newTd.insertBefore(newSpan, newTd.firstChild);
		newTr.insertBefore(newTd, newTr.firstChild);
		newTable.insertBefore(newTr, newTable.firstChild);
		newFieldset.appendChild(newTable);
	}
</script>

<script type="text/javascript">
	sureIt = function() {
		var selects = $('infosAll').getElementsByTagName('table');
		for(var i=0;i<selects.length;i++) {
			var eachSel = selects[i];
			var theSel = eachSel.getElementsByTagName('select')[0];
			var selNewId = eachSel.id;
			var selId = selNewId.substring(4) + 'sel';	//filter the "new_"
			var unselId = selNewId.substring(4) + 'unsel';
			$(selId).innerHTML = null;
			$(unselId).innerHTML = null;
			
			for(var j=0;j<theSel.options.length;j++) {	
				if(theSel.options[j].selected == true) {
					$(selId).options.add(new Option(theSel.options[j].text,theSel.options[j].value));	//.value
				}
				else {
					$(unselId).options.add(new Option(theSel.options[j].text,theSel.options[j].value));
				}
			}		
		}
		
		Yutil.hideDialog('_' + $('infosField').id + '_Dialog');
	}
	hideIt = function() {
		Yutil.hideDialog('_' + $('infosField').id + '_Dialog');
	}
</script>
<%@ page language="java" contentType="text/html; charset=utf-8" %>
